<?php
class Administrator_Model_UserType_UserType extends Administrator_Model_System {
	public $_name = "user_type";
	protected $_sequence = true;
	public function getAll() {
		$result = $this->select();
		return $this->fetchAll($result)->toArray();	

	}
	public function getItemsId($id){
		$result = $this->select();
		$result->where('id = ?',$id);
		return $this->fetchRow($result)->toArray();
	}
	static function getNamebyId($id)
	{
		$excute = new Administrator_Model_UserType_UserType();
		$query = $excute->select();
		$query->where('id = ?',$id);
		$result = $excute->fetchRow($query)->toArray();
		return $result['name'];
	}
	public function insertItem($data)
	{
		try {
		    $this->insert($data);
		} 
		catch (Exception $e) {
		    return $e->getMessage();
		}
		return "success";
		
	}
	public function updateItem($data,$id){
		try {
		    $this->update($data, "id = $id");
		} 
		catch (Exception $e) {
		    return $e->getMessage();
		}
		return "success";
	}
}